package com.foryang.springcloud.mapper;

import com.foryang.springcloud.entity.SystemUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserMapper {

    @Select("select * from tb_user where username = #{username}")
    SystemUser getByUsername(@Param("username") String username);

    @Select("select access_code from tb_permission p, tb_role r, tb_user_role ur, tb_user u where p.role_id = r.id " +
            "and r.id = ur.role_id " +
            "and ur.user_id = u.id " +
            "and u.username = #{username}")
    List<String> getPermission(@Param("username")String username);

}
